package salary.calculation.common;

import salary.calculation.common.exception.BaseException;
import org.apache.commons.lang3.StringUtils;

import java.util.Collection;

public interface Assert {

    BaseException newException(Object... args);

    BaseException newException(Throwable t, Object... args);

    default void assertNotNull(Object obj) {
        if (obj == null) {
            throw newException(obj);
        }
    }

    default void assertNotNull(Object obj, Object... args) {
        if (obj == null) {
            throw newException(args);
        }
    }

    default void assertNotBlank(String str){
        if(StringUtils.isBlank(str)){
            throw newException(str);
        }
    }


    default void assertNotEmpty(Collection collection){
        if (collection.isEmpty()){
            throw newException(collection);
        }
    }
}
